package com.ytjj.qmyx.admin.service.impl;

import com.ytjj.common.service.RedisService;
import com.ytjj.qmyx.admin.model.Admin;
import com.ytjj.qmyx.admin.service.AdminCacheService;
import com.ytjj.qmyx.admin.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class AdminCacheServiceImpl implements AdminCacheService {

    @Autowired
    private AdminService adminService;

    @Autowired
    private RedisService redisService;

    @Value("${redis.database}")
    private String REDIS_DATABASE;

    @Value("${redis.key.admin}")
    private String REDIS_KEY_ADMIN;

    @Override
    public void delAdmin(Integer id) {
        Admin admin = adminService.selectAdminById(id);
        if (admin != null) {
            String key = REDIS_DATABASE + ":" + REDIS_KEY_ADMIN + ":" + admin.getTel();
            redisService.delete(key);
        }
    }
}
